package com.example.curriculum.controller;

import com.example.curriculum.pojo.InBound;
import com.example.curriculum.pojo.ResponseMessage;
import com.example.curriculum.service.InBoundService;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController  //接口方法返回对象 转换成json文本
@RequestMapping("/InBound") // localhost:8088/InBound/**
public class InBoundController {
    @Resource
    private InBoundService inBoundService;

    @PostMapping
    public ResponseMessage<InBound> add(@Validated @RequestBody InBound inbound){
        InBound inboundnew = inBoundService.add(inbound);
        return ResponseMessage.success(inboundnew);
    }
    @GetMapping({"/{order_id}"})
    //输入的字符串需要进行URL编码后才能传入
    public ResponseMessage<InBound> select(@PathVariable String order_id){
        InBound inboundnew = inBoundService.select(order_id);
        return ResponseMessage.success(inboundnew);
    }
    @PutMapping
    public ResponseMessage<InBound> update(@Validated @RequestBody InBound inbound){
        InBound inboundnew = inBoundService.update(inbound);
        return ResponseMessage.success(inboundnew);
    }
    @DeleteMapping({"/{order_id}"})
    //输入的字符串需要进行URL编码后才能传入
    public ResponseMessage<InBound> delete(@PathVariable String order_id){
        inBoundService.delete(order_id);
        return ResponseMessage.success();
    }
}
